﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Properties;
using System.Data;
using IngressApp.BC;
namespace IngressApp
{
    /// <summary>
    /// Interaction logic for editLectores.xaml
    /// </summary>
    public partial class editLectores : UserControl
    {
        private int idSelectedItem = -1;
        public editLectores()
        {
            InitializeComponent();
            BCRead read = new BCRead();
            this.DataContext = read.readTiposHuellas().DefaultView;

        }

       

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            TipoHuella obj = new TipoHuella();
            obj.Clave = txtClave.Text;
            obj.Descripcion = txtDescripcion.Text;
            
            BCInsert ins = new BCInsert();
            MessageBox.Show(ins.insert(obj));

            //refreshFields();
            btnAdd.Visibility = Visibility.Hidden;

            this.DataContext = null;
            BCRead read = new BCRead();
            this.DataContext = read.readTiposHuellas().DefaultView;
        }

        private void btnAgregar_Click(object sender, RoutedEventArgs e)
        {
            btnAdd.Visibility = Visibility.Visible;
        }

     
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            TipoHuella obj = new TipoHuella();
            obj.Clave = txtClave.Text;
            obj.Descripcion = txtDescripcion.Text;

            idSelectedItem = Convert.ToInt32(txtSelectedItem.Text);

            BCUpdate up = new BCUpdate();
            MessageBox.Show(up.update(obj,idSelectedItem));

            //refreshFields();
            btnAdd.Visibility = Visibility.Collapsed;
        }

        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {

            idSelectedItem = Convert.ToInt32(txtSelectedItem.Text);
            BCDelete del = new BCDelete();
            MessageBox.Show(del.delTipoHuella(idSelectedItem));
            this.DataContext = null;
            BCRead read = new BCRead();
            this.DataContext = read.read().DefaultView;
        }

    }
}
